#pragma once

#include <map>
#include "IcemVolume.h"
#include "TalairachVolume.h"

enum VolumeId {mri,pet,stat,eeg,ct,mask,ctWithElectrodes,atlas,filteredAtlas,fMRI};

template<class T>
class IcemStack {
	std::map<VolumeId,std::tr1::shared_ptr<IcemVolume<T> > > volumeStack;
	std::tr1::shared_ptr<TalairachVolume> talairach;
	std::tr1::shared_ptr<TalairachVolume> filteredTalairach;
	size_t size[3];
	double minCoordinates[3];
	uchar3 *cudaImage[3];
	//float talairachPoints[3][9];
    
	cudaPitchedPtr renderedVolume;
	void UpdateRenderedVolume();

public:
	~IcemStack();
	void GetVolumesNumberAndSize(int* N, int* X, int* Y, int* Z);
	void GetRenderedVolumes(unsigned char* v, const char*** names, double** transformationMatrix);
	void AddVolume(int id, std::tr1::shared_ptr<IcemVolume<T> > volume);
	void AddTalairachVolume(std::tr1::shared_ptr<TalairachVolume> volume, bool filtered);
	int GetSliceSize(int dir, int* sizeX, int* sizeY);
	//float* GetSlice(int pos[3], int* sizeX, int* sizeY, int dir);
	void GetSlice(double pos[3],int dir, uchar3* result);
	void IcemStack<T>::ComputeSlice(double pos[3], int dir);
	int GetFirstSlice(double pos[3], int dir, uchar3* result);
	void SetColormap(int id, unsigned char cm[3*256]);
	void SetTalairachColormap(unsigned char cm[3*2000]) {talairach->SetTalairachColormap(cm);};
	void SetAlpha(int id, double alpha);
	void SetContrast(int id, double contrast);
	void SetBrightness(int id, double brightness);
    void SetFilterLimits(int id,float lowerLimit,float upperLimit);
    void SetTransformationMatrix (int id, float mat[4][4]);

};